//
//  WDServiceFinishView.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2025/4/2.
//

#import "WDServiceFinishView.h"
#import "WDArrivalServiceDetailModel.h"

@interface WDServiceFinishView ()
@property (nonatomic, strong) WDArrivalServiceDetailModel *taskDetailModel;

/// 关闭/取消原因
@property (nonatomic, strong) WDTaskDetailBasicSingleView *contentView;

/// 报单时间
@property (nonatomic, strong) WDTaskDetailBasicSingleView *handleTimeView;

/// 保单账号
@property (nonatomic, strong) WDTaskDetailBasicSingleView *handleAccountView;
@end

@implementation WDServiceFinishView

- (void)initWithSubView {
    [super initWithSubView];
    
    self.backgroundColor = [UIColor whiteColor];
    
    CGRect frame = CGRectMake(20, 0, self.width - 40, 1);
    [CALayer drawLine:self frame:frame lineColor:[UIColor colorWithHexString:@"#DDDDDD"]];
}

/// 处理时间
- (void)initWithHandleTimeView {
    if (!_handleTimeView) {
        CGRect frame = CGRectMake(0, self.contentView.bottom, self.width, kWDTaskDetailBasicSingleViewHeight);
        _handleTimeView = [[WDTaskDetailBasicSingleView alloc] initWithFrame:frame];
        [self addSubview:_handleTimeView];
    }
    if (self.taskDetailModel && self.taskDetailModel.taskFlowList.count > 0) {
        WDTaskFlowModel *model = self.taskDetailModel.taskFlowList.lastObject;
        [_handleTimeView updateWithViewTitle:@"报单时间" value:objectNull(model.createTime) valueHeight:18];
    }
}

/// 处理账号
- (void)initWithHandleAccountView {
    if (!_handleAccountView) {
        CGRect frame = self.handleTimeView.frame;
        frame.origin.y = self.handleTimeView.bottom;
        _handleAccountView = [[WDTaskDetailBasicSingleView alloc] initWithFrame:frame];
        [self addSubview:_handleAccountView];
    }
    if (self.taskDetailModel && self.taskDetailModel.taskFlowList.count > 0) {
        WDTaskFlowModel *model = self.taskDetailModel.taskFlowList.lastObject;
        [_handleAccountView updateWithViewTitle:@"报单账号" value:objectNull(model.engineerName) valueHeight:18];
    }
}

- (void)updateWithViewData:(id)data {
    self.taskDetailModel = data;
    
    /// 处理时间
    [self initWithHandleTimeView];
    
    /// 处理账号
    [self initWithHandleAccountView];
}


@end
